/*
 *  Object.h
 *  rayTracer
 *
 *  Created by Zachry Thayer on 10/6/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */
#ifndef _obj_h
#define _obj_h

#include "Vec3.h"
#include "Ray.h"
#include <limits>

class Material{
public:
	float reflect, refract;
	float r,g,b,a;
	//Material(Material mat): reflect(mat.reflect) ,refract(mat.refract), diffuse(mat.diffuse){}
	Material():  reflect(0.f) ,refract(0.f), r(0.0f), g(0.0f), b(0.0f),a(1.0f){}
};

class Intersect{
public:
	bool hit;
	float dist;
	int obj;
	Vec3 point;
	Vec3 normal;
	Vec3 reflect;
	Material mat;
	Intersect ():hit(false), dist(0),obj(-1), point(Vec3 (0,0,0)), normal(Vec3(0,0,0)), reflect(Vec3(0,0,0)), mat(Material()) {}
	Intersect (float dist, int o, Vec3 &p, Vec3 &n, Vec3 &r, Material &m):dist(dist),obj(o), point(p), hit(true), normal(n), reflect(r), mat(m){}
};

class Object{
private:
	Vec3 pos;
	Vec3 scl;
	Vec3 rot;
public:
	Material mat;

	Object():pos(Vec3(0,0,0)),scl(Vec3(1,1,1)), rot(Vec3(0,0,0)), mat(Material()){}
	Object(Vec3 &position, Vec3 &scale, Vec3 &rotation, Material &material):pos(position),scl(scale), rot(rotation), mat(material){}
	~Object(){}
	
	Vec3 getPosition();
	Vec3 getScale();
	Vec3 getRotation();
	
	void setMaterial(Material &material);
	Material getMaterial();
	
	
	void translate(Vec3 &offset);
	void moveTo(Vec3 &position);
	
	void scale(Vec3 &scaler);
	void setScale(Vec3 &newScale);
	
	void rotateX(float theta);
	void rotateY(float theta);
	void rotateZ(float theta);
	void rotate(Vec3 &rotator);
	void setRotation(Vec3 &rotation);
	
	virtual Intersect intersect(Ray &ray) = 0;	// subclass implemented	
	virtual bool inside(Vec3 &point) = 0;
	
};


#endif
